package com.swanclouds.redfish.account.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.swanclouds.model.account.LdapResource;
import com.swanclouds.redfish.common.redfish.MemberModel;

/**
 * @author 张立强
 * @version jdk1.8.0
 */
public class LdapResourceModel implements LdapResource {

    @JsonProperty("@odata.id")
    private String dataId;

    @JsonProperty("@odata.context")
    private String context;

    @JsonProperty("@odata.type")
    private String type;

    @JsonProperty("Id")
    private String id;

    @JsonProperty("Name")
    private String name;

    @JsonProperty("LdapServiceEnabled")
    private Boolean enabled;

    @JsonProperty("LdapControllers")
    private MemberModel ldapControllers;

    /**
     * 集合资源的访问路径 @odata.id
     *
     * @return dataId
     */
    @Override
    public String getDataId() {
        return this.dataId;
    }

    /**
     * 集合资源模型的描述信息 @odata.context
     *
     * @return context
     */
    @Override
    public String getContext() {
        return this.context;
    }

    /**
     * 集合资源的类型 @odata.type
     *
     * @return type
     */
    @Override
    public String getType() {
        return this.type;
    }

    /**
     * 资源名称 Name
     *
     * @return name
     */
    @Override
    public String getName() {
        return this.name;
    }
    /**
     * Ldap功能使能
     *
     * @return boolean
     */
    @Override
    public Boolean getLdapServiceEnabled() {
        return this.enabled;
    }

    /**
     * 域控制器集合路径
     *
     * @return odataId
     */
    @Override
    public String getLdapControllers() {
        return this.ldapControllers != null ? this.ldapControllers.getDataId() : null;
    }

    @Override
    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "LdapResourceModel {" +
                "dataId='" + dataId + '\'' +
                ", context='" + context + '\'' +
                ", type='" + type + '\'' +
                ", id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", enabled=" + enabled +
                ", ldapControllers=" + ldapControllers +
                '}';
    }
}
